package org.springblade.modules.admin.vo.parts;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.admin.entity.MaintainPartsWork;
import org.springblade.modules.admin.entity.MaintainPlanContentUser;
import org.springblade.modules.admin.enums.ApproveStatusEnum;
import org.springblade.modules.admin.enums.EmerProcTypeEnum;
import org.springblade.modules.admin.enums.WorkOrderTypeEnum;
import org.springblade.modules.admin.vo.LastPlanVO;
import org.springblade.modules.admin.vo.MalFunctionHistoryVO;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Date 14:14 2022/7/1
 * @Description {
 *   部件更换详情
 * }
 * @Author lsay
 **/
@Data
public class PartsWorkDetailVO {

	@JsonSerialize(using = ToStringSerializer.class)
	private Long planId;

	@JsonSerialize(using = ToStringSerializer.class)
	private Long elevatorId;

	private String processInstanceId;

	private String detailTitle;

	private Integer status;

	/**
	 * 审批id
	 */
	private Long approveId;

	/**
	 * 审批状态
	 */
	private Integer auditStatus;

	private String auditStatusName;

	private String buildingName;

	private String elevatorAddress;

	private String partsId;

	private String partsName;

	private String floorStandIds;

	private String floorStandNames;

	private String partsModel;

	private Integer num;

	private String desc;

	/**
	 * 停梯状态
	 */
	private Integer elevatorStop;

	/**
	 * 实时停梯状态
	 */
	private Integer isStop;

	@ApiModelProperty(value = "部件关联的类目id")
	private Long categoryId;

	@ApiModelProperty(value = "申请时，部件关联的skuId")
	private Long skuId;

	@TableField(typeHandler = JacksonTypeHandler.class)
	@ApiModelProperty(value = "sku配件信息")
	private JSONObject skuPartsInfo;

	@ApiModelProperty(value = "审批后，部件关联的skuId")
	private Long finallySkuId;

	@ApiModelProperty(value = "审批后，关联sku配件信息")
	@TableField(typeHandler = JacksonTypeHandler.class)
	private JSONObject finallySkuPartsInfo;

	/**
	 * 描述图片及视频
	 */
	@TableField(typeHandler = JacksonTypeHandler.class)
	private List<HashMap<String,String>> otherUrl;

	/**
	 * word附件
	 */
	@TableField(typeHandler = JacksonTypeHandler.class)
	private List<HashMap<String,String>> extWordUrl;

	/**
	 * 配件基础信息
	 */
	private String partsInfo;

	@TableField(typeHandler = JacksonTypeHandler.class)
	@ApiModelProperty(value = "其它配件信息")
	private Map<String,Object> otherInfo;

	@JsonSerialize(using = ToStringSerializer.class)
	private Long createUser;

	/**
	 * 申请人名称
	 */
	private String createUserName;

	/**
	 * 申请时间
	 */
	private Date createTime;

	/**
	 * 关联维修任务详情
	 */
	private CorrelationMalfunctionDetailVO malDetailVO;

	/**
	 * 最近一次任务
	 */
	private LastPlanVO lastPlanVO;

	/**
	 * 维修操作记录
	 */
	private List<MalFunctionHistoryVO> malFunctionHistories;

	/**
	 * 关联任务的用户
	 */
	private List<MaintainPlanContentUser> planContentUsers;

	/**
	 * 紧急程度
	 */
	private Integer emerProcType;

	/**
	 * 工单类型
	 */
	private Integer workOrderType;

	/**
	 * 紧急程度描述
	 */
	private String emerProcTypeName;

	/**
	 * 工单类型描述
	 */
	private String workOrderTypeName;

	/**
	 * 项目id
	 */
	private Long buildingId;

	/**
	 * 项目类型
	 */
	private Integer type;

	/**
	 * 项目类型名称
	 */
	private String typeName;

	/**
	 * 2025-06 新增单位名称字段
	 */
	@ApiModelProperty("单位名称")
	private String unitNameValue;

	private List<MaintainPartsWork> partsList;

	public void setPartsName(String partsName) {
		if(Func.isNotEmpty(partsName)){
			this.partsName = partsName.replace("&amp;&amp;",">");
		}
	}

	public void setFloorStandNames(String floorStandNames) {
		if(Func.isNotEmpty(floorStandNames)){
			this.floorStandNames = floorStandNames.replace("&amp;&amp;",">");
		}
	}

	public void setEmerProcType(Integer emerProcType) {
		if(Func.isNotEmpty(emerProcType)){
			this.emerProcTypeName = EmerProcTypeEnum.getName(emerProcType);
		}
		this.emerProcType = emerProcType;
	}

	public void setWorkOrderType(Integer workOrderType) {
		if(Func.isNotEmpty(workOrderType)){
			this.workOrderTypeName = WorkOrderTypeEnum.getName(workOrderType);
		}
		this.workOrderType = workOrderType;
	}

	public void setAuditStatus(Integer auditStatus) {
		if(Func.isNotEmpty(auditStatus)){
			this.auditStatusName = ApproveStatusEnum.getName(auditStatus);
		}
		this.auditStatus = auditStatus;
	}
}
